#!/bin/sh
OK=0
WARN=1
CRITICAL=2
UNKNOWN=3

	info_slc5=`grep "uploading with command: /usr/lxslc/sbin/bestNodes2Ldap-slc5 --upload" /var/log/lb/lbd.log | tail -1`
        info_slc6=`grep "uploading with command: /usr/lxslc/sbin/bestNodes2Ldap-slc6 --upload" /var/log/lb/lbd.log | tail -1`
	infos_slc5=${info_slc5%% uploading*}
	infos_slc6=${info_slc6%% uploading*}

	time_now=`date`
	data_time_now=`date -d "$time_now" +"%s"`
	data_time_get5=`date -d "$infos_slc5" +"%s"`
	data_time_get6=`date -d "$infos_slc6" +"%s"`

	value_5=`expr $data_time_now - $data_time_get5`
	value_6=`expr $data_time_now - $data_time_get6`
	process5_num=`ps -ef | grep -v grep | grep "lbd-slc5" -c`
	process6_num=`ps -ef | grep -v grep | grep "lbd-slc6" -c`


		if [ $value_5 -le 600 ] && [ $value_6 -le 600 ] && [ $process5_num -ge 1 ] && [ $process6_num -ge 1 ]
		then
			echo "process is ok"
			exit $OK
		else
			echo "process is not running"
			exit $CRITICAL		
		fi
